package com.niiwoo.civet.account.enums;

import com.niiwoo.tripod.provider.exception.NoSuchEnumValueException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * app上查询用户账单列表的筛选条件项
 * Created by xiaoyingping on 2018/11/2.
 */
@AllArgsConstructor
@Getter
public enum BillBusinessTypeEnum {
    INVEST("10", "投资","https://image.niiwoo.com/activity-manage/20181105/6b24527b-1ecf-4020-b698-0abe36b82bdb.png"),
    CREDITOR_TRANSFER("11", "转让","https://image.niiwoo.com/activity-manage/20181105/a3928ea0-9c22-4801-941d-cad47a821c79.png"),
    RECEIVED_REPAYMENT("12", "回款","https://image.niiwoo.com/activity-manage/20181105/c05ef16e-9db1-4e3a-8738-0f147c291b19.png"),
    RECHARGE("13", "充值","https://image.niiwoo.com/activity-manage/20181105/39304491-d000-4600-9270-a409e2ec8d43.png"),
    WITHDRAW("14", "提现","https://image.niiwoo.com/activity-manage/20181105/1ea9cba4-5fac-4c7d-94f8-b0cdc299ab6c.png"),
    BACKSPACE("15", "退款","https://image.niiwoo.com/activity-manage/20181105/f4409308-76d7-4e84-8cd1-2ac6eaebdc3d.png"),
    LEND("16", "借款","https://image.niiwoo.com/activity-manage/20181105/7777e45e-cc31-457f-a4e4-1536cf2b4e2f.png"),
    REPAYMENT("17", "还款","https://image.niiwoo.com/activity-manage/20181105/6d163316-27d2-4593-90c4-a36c29ae96c3.png"),
    PRIZED("18", "奖励","https://image.niiwoo.com/activity-manage/20181105/c8f05d01-0c47-48dc-90c6-34fc652e9adf.png"),
    OTHER("19", "其他","https://image.niiwoo.com/activity-manage/20181105/0867acf9-62cf-40da-990d-532c00d9bd09.png");


    public static BillBusinessTypeEnum enumOf(String code){
        for (BillBusinessTypeEnum billBusinessTypeEnum : values()) {
            if (billBusinessTypeEnum.code.equals(code)) {
                return billBusinessTypeEnum;
            }
        }
        throw new NoSuchEnumValueException("BillBusinessTypeEnum:"+code);
    }


    public static List<Byte> getOrderTypes(String code){
        List<Byte> orderTypeEnums = new ArrayList<>();

        BillBusinessTypeEnum billBusinessTypeEnum = BillBusinessTypeEnum.enumOf(code);
        if(Objects.nonNull(billBusinessTypeEnum)){
            for (OrderTypeEnum orderTypeEnum : OrderTypeEnum.values()) {
                if (orderTypeEnum.getBillBusinessTypeEnum() == billBusinessTypeEnum) {
                    orderTypeEnums.add(orderTypeEnum.getCode());
                }
            }
        }

        return orderTypeEnums;
    }












    private String code;
    private String desc;
    private String headImgUrl;//账单头像，通过神盾将图片上传
}
